#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long
#define uint unsigned int

#define YES cout << "Yes" << endl
#define NO cout << "No" << endl

const int INF = 1e9;
using namespace std;
/*思考
 *枚举子序列的首尾元素，判断是否满足条件
 *如果满足条件，更新最大长度
 *最后输出n-最大长度
 */
void solve()
{
    int n;
    cin >> n;

    vector<int> a(n);
    for (int& x : a) cin >> x;
    sort(a.begin(), a.end());

    int maxLen = 1;

    for (int i = 0; i < n; ++i) {
        for (int j = n - 1; j >= i; --j) {
            if ((a[i] + a[j]) % 2 == 0) {
                maxLen = max(maxLen, j - i + 1);
                break;
            }
        }
    }
    cout << n - maxLen << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t = 0;
    cin >> t;
    while (t--)
        solve();
    return 0;
}